//
//  LOLFuwenViewController.m
//  LOLXXbox
//
//  Created by mac on 16/2/29.
//  Copyright © 2016年 Grasstrio. All rights reserved.
//

#import "LOLFuwenViewController.h"
#import "LSZNetWorkTools.h"
#import "LOLFuwenModel.h"
#import "LOLFuwenbrowserViewController.h"
#define WIDTH [[UIScreen mainScreen]bounds].size.width
#define HEIGHT [[UIScreen mainScreen]bounds].size.height

#define PADDING5 WIDTH/75
#define TOPCHOOSEHEIGHT 30
#define TOPHEIGHT 64
#define BOTTOMHEIGHT 49
#define PADDING10 WIDTH/37.5
#define GIFTFUWEN(name)  [NSString stringWithFormat:@"http://box.dwstatic.com/apiHeroSuggestedGiftAndRun.php?hero=%@",name]



@interface LOLFuwenViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,retain)NSMutableArray *modelArr;
@property(nonatomic,retain)UITableView *tableView;
@end

@implementation LOLFuwenViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"天赋符文";
    self.tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-TOPHEIGHT-BOTTOMHEIGHT) style:UITableViewStylePlain];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];

    
    
    [self createData];

}

-(void)createData {

        [LSZNetWorkTools getWithUrl:GIFTFUWEN(self.enName) parameter:nil httpHeader:nil resposeType:ResponseTypeJSON success:^(id result) {
            self.modelArr = [LOLFuwenModel baseModelByArr:result];
            [self.tableView reloadData];
            
        } fail:^(NSError *error) {
            
            
        }];
        

   
        
        
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.modelArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *reuse=@"giftrunReuse";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuse];
    }
    LOLFuwenModel *model=self.modelArr[indexPath.row];
    
    cell.textLabel.text=model.title;
    cell.detailTextLabel.text=model.des;
    
    return cell;
    
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    LOLFuwenbrowserViewController *gfVC=[[LOLFuwenbrowserViewController alloc]init];
    gfVC.fuwenModel=self.modelArr[indexPath.row];
    [self presentViewController:gfVC animated:YES completion:nil];
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
